{% extends "ErpBundle::layout.html.twig" %}
{% block title %}{{ parent() }} - Evenements{% endblock %}
{% block body %}
<script type="text/javascript">
$(document).ready(function(){
	$('#paging_container').pajinate({
        items_per_page : 5,
        abort_on_small_lists: true
	});
	$('li.inContent:odd, .content > *:odd').css('background-color','#C7F66F');
	$('li.inContent:odd button, .content > *:odd').css('background-color','#C7F66F');
});
</script>
<div id="paging_container" class="container">
   <table><tr><td class="eventTab1"><div class="page_navigation"></div></td><td class="eventTD2">Supprimer :</td><td class="eventTD3">Participants</td></tr></table>
   <ul class="content">
  {% for e in event %}
	    <li class="inContent"><table><tr><td class="eventTD1">{{ e.nom }}, publi&eacute; le {{ e.date|date("d/m/Y")}} &agrave; {{ e.date|date("G:i:s") }}</td>
	    <td class="eventTD2">	
	    <div id="formEvent">
	    <form id="deleteEvent{{e.id}}" class="deleteEvent">  
	    <input type="hidden" class="idEvent" name="_id" value="{{e.id}}" />   
	    <input type="image" class="buttonEvent"
	   
		 src="{{ asset('bundles/erp/images/13.png') }}"
	     alt="Submit" />
	     </form></div></td>
	      <td id="viewContainer{{e.id}}" class="eventTD3">	
      	 	 	<a class="pop_a" href="viewAllEvent/{{e.id}}" id="pop_a{{e.id}}">
      	 	 		<img type="image" class="imgPop"src="{{ asset('bundles/erp/images/10.png') }}" />
      	 	 		<input type="hidden" class="idEvent" name="_id" value="{{e.id}}" /> 
      	 	 	</a> 
	      </td>
	     </tr><tr><td class="eventTD1">
	    {{ e.description }}</td></tr></table></li>
  {% endfor %}
   </ul>
   <div class="page_navigation"></div>		
</div>
		<a href="{{ asset('app_dev.php/erp/creer_evenement') }}">Cr&eacute;er un &eacute;v&egrave;nement</a>
		<a href="{{ asset('app_dev.php/erp/afficher_evenement') }}">Retour</a>
<script>
	  $(".deleteEvent").submit(function(){
		 var id = $(this).children('.idEvent').val();
			 var src = "{{ asset('bundles/erp/images/3.png') }}";
		        if (confirm('Etes vous sur de vouloir supprimer cet evenement ?')) {
					 $.ajax({
						  url: 'delete_evenement/'+id+'',
						  success: function(data) {
							  $("#deleteEvent"+id+"").parent().parent().parent().parent().parent().parent().remove();
						  }  
					  		       		
						});
						 return false;
		        }
		        else{
					return false;
		        }
		 });

	$(".pop_a").click(function(){

			//alert(html);
			var html = $(this).html();
			var id = $(this).children('.idEvent').val();
			var popin = $(this).popin({
				width:250,
				height:250,
				className: "eventpopin",
				onStart: function() {
					$("#pop_a"+id+"").empty();
				},
				onComplete: function() {
				},
				onExit: function() {
					$("#pop_a"+id+"").html(html);
				}
			});
			return false;
		});
		
</script>
{% endblock %}
